package cn.itlaobing.eshop.service;

import cn.itlaobing.eshop.dao.GoodsDao;
import cn.itlaobing.eshop.entity.Itlb_goods;
import cn.itlaobing.eshop.entity.SaleDTO;
import cn.itlaobing.eshop.entity.BaseGoods;
import cn.itlaobing.eshop.entity.ItlbFocuss;
import cn.itlaobing.eshop.exception.BusinessException;


import java.sql.SQLException;
import java.util.List;


/**
 * @Description:
 * @Author: WangDong
 * @Date: 2017/11/13 19:26
 */
public class GoodsService {
    private GoodsDao goodsDao=new GoodsDao();
    public List<BaseGoods> queryAll() throws BusinessException {
        List<BaseGoods>list=null;
        try {
            list=goodsDao.QueryAll();
        } catch (SQLException e) {
            e.printStackTrace();
            throw new BusinessException(e.getMessage());
        }
        return list;
    }


   /* public Map<String,Object> queryCounts()throws BusinessException{
        Map<String,Object> map=null;
        try {
            map=goodsDao.queryCounts();
        } catch (SQLException e) {
            e.printStackTrace();
            throw new BusinessException(e.getMessage());
        }
        return  map;
    }*/
    public List<SaleDTO> findCounts()throws BusinessException  {
        List<SaleDTO>list=null;
        try {
            list=goodsDao.findCounts();
        } catch (SQLException e) {
            e.printStackTrace();
            throw new BusinessException(e.getMessage());
        }
        return list;
    }
    public List<SaleDTO> findNew() throws BusinessException {
        List<SaleDTO>list=null;
        try {
            list=goodsDao.findNew();
        } catch (SQLException e) {
            e.printStackTrace();
            throw new BusinessException(e.getMessage());
        }
        return list;
    }
    public List<ItlbFocuss> findPictures() throws BusinessException{
        List<ItlbFocuss> list=null;
        try {
            list=goodsDao.findPictures();
        } catch (SQLException e) {
            e.printStackTrace();
            throw new BusinessException(e.getMessage());
        }
        return list;
    }
    //查询详情页
    public Itlb_goods query(int id) throws BusinessException{
        Itlb_goods itlbGoods=null;
        try {
            itlbGoods=goodsDao.query(id);
        } catch (SQLException e) {
            e.printStackTrace();
            throw new BusinessException(e.getMessage());
        }
        return  itlbGoods;
    }

}
